<?php

namespace App\Http\Controllers\admin;

use App\Dao\BankDao;
use App\Exceptions\SysExceptions;
use App\Services\Code;

class BankController extends BaseController
{
    public function banks()
    {
        if(getIsHasPage()){
            return Code::message('',200,BankDao::pageinate(request()->all()));
        }
        return view('admin.banks.banks');
    }

    public function add()
    {
        if(isPost()){
            $params = request()->all();
            BankDao::add_bank($params);
            return  Code::message('',200);
        }
        return view('admin.banks.add');
    }

    /**
     * @throws SysExceptions
     */
    public function update()
    {
        if(isPost()){
            $params = request()->all();
            BankDao::update_bank($params);
            return  Code::message('',200);
        }
        return view('admin.banks.edit',[
            'info'=>BankDao::info(request()->all())
        ]);
    }
}
